package com.th.therp.mapper;

import com.th.therp.pojo.emtity.Vendor;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VendorMapper {

    //查询全部供应商
    @Select("select * from vendor where is_deleted = 0")
    List<Vendor> list();

    //新增供应商
    @Insert("insert into vendor (name,contact,phone,email,is_deleted) values (#{name},#{contact},#{phone},#{email},0)")
    void add(Vendor vendor);

    //修改供应商
    void update(Vendor vendor);

    //根据id查询供应商名称
    @Select("select name from vendor where id=#{vendorId}")
    String findNameById(Integer vendorId);

    //根据名称查询供应商
    @Select("select * from vendor where name=#{name} and is_deleted=0")
    Vendor findByName(String name);
}